package com.thirteengroup.casemg.controller;


import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.thirteengroup.casemg.domain.Employee;
import com.thirteengroup.casemg.service.IEmployeeService;

import java.util.ArrayList;
import java.util.List;

public class EmployeeReadListener extends AnalysisEventListener<Employee> {


    private IEmployeeService employeeService;

    public EmployeeReadListener(IEmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    private List<Employee> employeelist=new ArrayList<>();
    @Override
    public void invoke(Employee employee, AnalysisContext analysisContext) {
        employeelist.add(employee);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

        //应当批量插入

        employeeService.batchInsert(employeelist);
//        for (Employee employee:
//             employeelist) {
//            employeeService.insertDept(employee);
//        }
    }
}
